package com.ruoyi.rsikManage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rsikManage.domain.TRiskOrgidUnitcode;
import com.ruoyi.rsikManage.service.ITRiskOrgidUnitcodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 组织、煤矿编号对应关系Controller
 * 
 * @author sxygsj
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/rsikManage/unitcode")
public class TRiskOrgidUnitcodeController extends BaseController
{
    @Autowired
    private ITRiskOrgidUnitcodeService tRiskOrgidUnitcodeService;

    /**
     * 查询组织、煤矿编号对应关系列表
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRiskOrgidUnitcode tRiskOrgidUnitcode)
    {
        startPage();
        List<TRiskOrgidUnitcode> list = tRiskOrgidUnitcodeService.selectTRiskOrgidUnitcodeList(tRiskOrgidUnitcode);
        return getDataTable(list);
    }

    /**
     * 导出组织、煤矿编号对应关系列表
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:export')")
    @Log(title = "组织、煤矿编号对应关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRiskOrgidUnitcode tRiskOrgidUnitcode)
    {
        List<TRiskOrgidUnitcode> list = tRiskOrgidUnitcodeService.selectTRiskOrgidUnitcodeList(tRiskOrgidUnitcode);
        ExcelUtil<TRiskOrgidUnitcode> util = new ExcelUtil<TRiskOrgidUnitcode>(TRiskOrgidUnitcode.class);
        util.exportExcel(response, list, "组织、煤矿编号对应关系数据");
    }

    /**
     * 获取组织、煤矿编号对应关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tRiskOrgidUnitcodeService.selectTRiskOrgidUnitcodeById(id));
    }

    /**
     * 新增组织、煤矿编号对应关系
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:add')")
    @Log(title = "组织、煤矿编号对应关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRiskOrgidUnitcode tRiskOrgidUnitcode)
    {
        return toAjax(tRiskOrgidUnitcodeService.insertTRiskOrgidUnitcode(tRiskOrgidUnitcode));
    }

    /**
     * 修改组织、煤矿编号对应关系
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:edit')")
    @Log(title = "组织、煤矿编号对应关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRiskOrgidUnitcode tRiskOrgidUnitcode)
    {
        return toAjax(tRiskOrgidUnitcodeService.updateTRiskOrgidUnitcode(tRiskOrgidUnitcode));
    }

    /**
     * 删除组织、煤矿编号对应关系
     */
    @PreAuthorize("@ss.hasPermi('rsikManage:unitcode:remove')")
    @Log(title = "组织、煤矿编号对应关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRiskOrgidUnitcodeService.deleteTRiskOrgidUnitcodeByIds(ids));
    }
}
